//
//  PayBankListTableViewCell.m
//  wangzhe
//
//  Created by 李 佳伟 on 2017/11/24.
//  Copyright © 2017年 李 佳伟. All rights reserved.
//

#import "PayBankListTableViewCell.h"
#import "JTCSM.h"

static CGFloat top = 15;
static CGFloat space = 20;
static CGFloat imagesize = 40;
static CGFloat labelHeight = 30;

@interface PayBankListTableViewCell ()
{
    UIImageView *headerImagev;
    UILabel *banknameLabel;
    UILabel *bankcardLabel;
}
@property (nonatomic,strong) UIButton *selectButton;
@end
@implementation PayBankListTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier celltype:(celltype)type{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [df lineViewWithHeightofTop:top superView:self.contentView spacing:-150 color:RGBACOLOR(241, 241, 241, 1) lineHeight:top];
        
        headerImagev = [[UIImageView alloc]initWithFrame:CGRectMake(space, top*2+(labelHeight*2-imagesize)/2, imagesize, imagesize)];
        [self.contentView addSubview:headerImagev];
        
        
        banknameLabel = [UILabel initWithFrame:CGRectMake(KVIEW_X(headerImagev)+space, top*2, KSCREENWidth, labelHeight) text:@"" font:16 textAlignment:NSTextAlignmentLeft texcolor:RGBACOLOR(89, 89, 89, 1) backgroundColor:nil];
        [self.contentView addSubview:banknameLabel];
        
        bankcardLabel = [UILabel initWithFrame:CGRectMake(KVIEW_X(headerImagev)+space, KVIEW_Y(banknameLabel), KSCREENWidth, labelHeight) text:@"" font:16 textAlignment:NSTextAlignmentLeft texcolor:RGBACOLOR(89, 89, 89, 1) backgroundColor:nil];
        [self.contentView addSubview:bankcardLabel];
        
        if (type == IsChoiceCellType) {
            CGFloat selectbuttonsize = 25;
            self.selectButton = [UIButton buttonWithType:UIButtonTypeCustom];
            self.selectButton.frame = CGRectMake(KSCREENWidth-space-selectbuttonsize, (KVIEW_Y(bankcardLabel)+2*top-selectbuttonsize)/2, selectbuttonsize, selectbuttonsize);
            [self.selectButton setImage:[UIImage imageNamed:@"充值_未选中.png"] forState:UIControlStateNormal];
            [self.selectButton setImage:[UIImage imageNamed:@"充值_选中.png"] forState:UIControlStateSelected];
            [self.contentView addSubview:self.selectButton];
        }
        
        [df lineViewWithHeightofTop:KVIEW_Y(bankcardLabel)+top superView:self.contentView spacing:0 color:nil lineHeight:top];
        
    }
    
    return self;
}
- (void)setvalueWithModel:(MyBankCardModel *)model{
    
    banknameLabel.text = model.bank_name;
    bankcardLabel.text = model.bank_card;
    [headerImagev sd_setImageWithURL:[NSURL URLWithString:model.bank_logo]];
    
}
@end
